import React from 'react';
import { SearchOutlined, RedoOutlined } from '@ant-design/icons';
import { Button, Col, Form, Input, Row, Select, Table } from 'antd';
import { SourcingColumns } from '../mconfig';
import { ISourceIntentionAPI } from '../common/type';
import { commonPageSizeOptions, showTotalInfo } from '@/common/constVariable';
import { SourceModalTableServices } from '../services';
import { arrList } from '../common/mock';

const UpdateTable: React.FC<ISourceIntentionAPI.IUpdataTable> = ({ curRes, onSaveSelectRow, defaultSourceKey }) => {
  /**Table的services*/
  // const { getSourceTableDateGrid, sourcePagination } = SourceModalTableServices(curRes);

  const preflxCls = 'source-modal-';

  /** 表单Form */
  const [searchForm] = Form.useForm();

  /**Table分页方法*/
  const handlePaginationChange = (page: number, pageSize: number) => {
    const params = {
      page: page,
      rows: pageSize,
    };
  };

  return (
    <div className={preflxCls + 'UpdateModalTable'}>
      <Form form={searchForm}>
        <Row gutter={[8, 0]} style={{ padding: '10px 1rem' }}>
          <Col span={4}>
            <Form.Item name="projectName">
              <Input placeholder="项目名称" allowClear />
            </Form.Item>
          </Col>
          <Col span={4}>
            <Form.Item name="packName">
              <Input placeholder="标的名称" allowClear />
            </Form.Item>
          </Col>
          <Col span={4}>
            <Form.Item name="businessType">
              <Select placeholder="标的类型" allowClear></Select>
            </Form.Item>
          </Col>
          <Col span={4}>
            <Form.Item name="orderType">
              <Select
                placeholder="标的类别"
                allowClear
                // loading={mapLoading}
              >
                {/* {
                                    loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_SUPPLY}`]?.map((item: any) => {
                                        return (
                                            <Select.Option key={item?.id} id={item?.id}>
                                                {item?.name}
                                            </Select.Option>
                                        );
                                    })
                                } */}
              </Select>
            </Form.Item>
          </Col>

          <Col span={8} style={{ textAlign: 'right' }}>
            <Button style={{ margin: '0 7px' }} type="primary" icon={<SearchOutlined />} onClick={() => {}}>
              查询
            </Button>
            <Button icon={<RedoOutlined />} onClick={() => {}}>
              重置
            </Button>
          </Col>
        </Row>
      </Form>
      <div className={'list-table'}>
        <Table
          bordered
          size="small"
          columns={SourcingColumns as any}
          dataSource={arrList}
          loading={false}
          scroll={{ x: 500, y: 500 }}
          rowKey={(record: any) => record?.id}
          rowSelection={{
            type: 'radio',
            selectedRowKeys: defaultSourceKey,
            onChange: (rowKey) => {
              onSaveSelectRow(rowKey);
            },
          }}
          // pagination={{
          //   showQuickJumper: true,
          //   showSizeChanger: true,
          //   pageSizeOptions: commonPageSizeOptions,
          //   showTotal: showTotalInfo,
          //   onChange: handlePaginationChange,
          //   pageSize: sourcePagination?.pageSize,
          //   current: sourcePagination?.current,
          //   total: sourcePagination?.total,
          // }}
          onRow={(record) => {
            return {
              onClick: () => {
                // table表格单选
                onSaveSelectRow([record?.id]);

                // table表格多选
                // const selectRow = arrList?.find((item: any) => item?.id == record?.id);
                // let flag = defaultSourceKey?.indexOf(selectRow?.id);
                // if (flag === -1) {
                //   onSaveSelectRow([...defaultSourceKey, selectRow?.id]);
                // } else {
                //   let newRowKey = [...defaultSourceKey];
                //   newRowKey?.splice(flag, 1);
                //   onSaveSelectRow(newRowKey);
                // }
              },
            };
          }}
        />
      </div>
    </div>
  );
};
export default UpdateTable;
